package com.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.example.entity.dto.KeepGetPageDto;
import com.example.entity.matirx.KeepGetRecord;
import com.example.entity.vo.KeepGetVo;
import com.example.exception.BaseException;
import com.example.mapper.KeepGetRecordMapper;
import com.example.service.KeepGetRecordService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class KeepGetRecordServiceImpl extends ServiceImpl<KeepGetRecordMapper, KeepGetRecord> implements KeepGetRecordService {
    @Autowired
    private KeepGetRecordMapper getRecordMapperMapper;

    @Override
    public void returned(KeepGetRecord record) {
        int i = getRecordMapperMapper.updateStatusAndBackOkById(record);
        if (i<=0){
            throw new BaseException("归还失败!");
        }
    }

    @Override
    public Page<KeepGetVo> pageVowithMoudleName(KeepGetPageDto record) {
        PageHelper.startPage(record.getPage(),record.getPageSize());
        Page<KeepGetVo> keepGetRecords = getRecordMapperMapper.pageVowithMoudleName(record);
        return keepGetRecords;
    }
}
